package com.xxx.pojo.bean;

import java.io.Serializable;

/**
 * 接口返回基类（带业务数据）
 */
public class ResponseDTO extends BaseDTO implements Serializable {

	private static final long serialVersionUID = -1216738729225915496L;
	
	private Object data; // 业务数据

	public ResponseDTO(int code, String msg, Object data) {
		super(code, msg);
		this.data = data;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public static ResponseDTO builtSuccess() {
		return builtSuccess(null);
	}

	public static ResponseDTO builtSuccess(Object data) {
		return new ResponseDTO(SUCCESS, MSG_SUCCESS, data);
	}

	public static ResponseDTO builtSuccess(String msg, Object data) {
		return new ResponseDTO(SUCCESS, msg, data);
	}

	public static ResponseDTO builtFail() {
		return new ResponseDTO(FAILD, MSG_FAILD, null);
	}

	public static ResponseDTO builtFail(String msg) {
		return new ResponseDTO(FAILD, msg, null);
	}

	public static ResponseDTO builtFail(int code, String msg) {
		return new ResponseDTO(code, msg, null);
	}

	public static ResponseDTO builtInvalidRequest() {
		return new ResponseDTO(INVALID_REQUEST, MSG_INVALID_REQUEST, null);
	}

	public static ResponseDTO builtInvalidRequest(String msg) {
		return new ResponseDTO(INVALID_REQUEST, msg, null);
	}

	public static ResponseDTO builtErrorParam() {
		return new ResponseDTO(ERROR_PARAM, MSG_ERROR_PARAM, null);
	}

	public static ResponseDTO builtInvalidHeader() {
		return new ResponseDTO(INVALID_HEADER, MSG_INVALID_HEADER, null);
	}

	public static ResponseDTO builtException() {
		return new ResponseDTO(EXCEPTION, MSG_EXCEPTION, null);
	}

	public static ResponseDTO builtNotLogin() {
		return new ResponseDTO(NOT_LOGON, MSG_NOT_LOGIN, null);
	}

	public static ResponseDTO builtTokenExpired() {
		return new ResponseDTO(TOKEN_EXPIRED, MSG_TOKEN_EXPIRED, null);
	}
	
}
